﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Kingdom_of_the_Dragon
{
    class Fireball
    {
        Vector2 position;
        public int lifetime;
        Vector2 direction;
        Texture2D picture;
        float speed;
        float angle_direct;
        float radians_direct;

        public Fireball(Texture2D firePicture, Vector2 startPosition, float
        updateSpeed, float angle_direct)
        {
            picture = firePicture;
            position = startPosition;
            speed = updateSpeed;
            this.angle_direct = angle_direct;
            radians_direct = MathHelper.ToRadians(angle_direct);
        }

        public Vector2 Position { get { return position; } }
        public float Speed { get { return speed; } }

        public void Draw(SpriteBatch batch, Vector2 cameraorigem)
        {
            batch.Begin();
            batch.Draw(picture, new Rectangle((int)cameraorigem.X + (int)position.X, (int)cameraorigem.Y + (int)position.Y,
                (int)picture.Width, (int)picture.Height),
                new Rectangle(0, 0, picture.Width, picture.Height),
                Color.White, radians_direct,
                new Vector2(picture.Width / 2, picture.Height / 2),
                SpriteEffects.None, 0f);
            batch.End();
        }

        public void Update(GameTime gameTime)
        {
            direction  = new Vector2(((float)Math.Cos(Convert.ToDouble(MathHelper.ToRadians(angle_direct - 90))) * (speed / 10)), ((float)Math.Sin(Convert.ToDouble(MathHelper.ToRadians(angle_direct - 90)))) * (speed / 10));
            position += direction;
            lifetime++;
        }
    }
}

      